package edu.washburn.cm333.project.entities;

import java.io.File;

import javax.persistence.EntityManagerFactory;

import edu.washburn.cm333.project.gui.MainForm;
import edu.washburn.cm333.project.gui.Preferences;


public class Main {

  public static void main(String[] args) {
	  File properties = new File(PropertyManager.PROPERTY_FILE_NAME);
//	  if(!properties.exists())
//		  new Preferences().setVisible(true);
	  new MainForm().setVisible(true);
//    factory = Persistence.createEntityManagerFactory("CAFM");
//    EntityManager em = factory.createEntityManager();
//    // read the existing entries and write to console
//	List<Tenant> tenantList = em.createQuery("select t from Tenant t",Tenant.class).getResultList();
//    for (Tenant todo : tenantList) {
//      System.out.println(todo.getId());
//    }
//    System.out.println("Size: " + tenantList.size());
//	List<Property> propertyList = em.createQuery("select t from Property t",Property.class).getResultList();
//    for (Property todo : propertyList) {
//      System.out.println(todo.getId());
//    }
//    System.out.println("Size: " + propertyList.size());
//	List<Lease> leaseList = em.createQuery("select t from Lease t",Lease.class).getResultList();
//    for (Lease todo : leaseList) {
//      System.out.println(todo.getId()+" "+todo.getTenants().getFName()+" "+todo.getProperty().getStreetAddress());
//    }
//    System.out.println("Size: " + leaseList.size());

    // create new todo
//    em.getTransaction().begin();
//    Tenant todo = new Tenant();
//    todo.setFName("fname");
//    todo.setLName("lname");
//    todo.setTaxId("taxId");
//    Property todo = new Property();
//    todo.setCity("Topeka");
//    todo.setState("KS");
//    todo.setStreetAddress("1700 College");
//    todo.setUnit("01");
//    todo.setZip("12345");
//    Lease todo = new Lease();
//    todo.setRent("123");
//    todo.setTermMonths(1);
//    todo.setProperty(em.createQuery("select t from Property t where t.id = '51'",Property.class).getSingleResult());
//    todo.setTenants(em.createQuery("select t from Tenant t where t.id = '1'",Tenant.class).getSingleResult());
//    em.persist(todo);
//    em.getTransaction().commit();

//    em.close();
  }
} 